package com.google.evCalcSuite.torcCalc;

import com.google.evCalcSuite.R;
import com.google.evCalcSuite.evCalcMain;
import com.google.evCalcSuite.R.layout;
import android.view.View.OnClickListener;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class TorqueCalcMain extends Activity {

	EditText forceEditText;
	EditText distanceEditText;
	Button calculateButton;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.torque_calc);

		forceEditText = (EditText) findViewById(R.id.torqueCalc_forceEditText);
		distanceEditText = (EditText) findViewById(R.id.torqueCalc_distanceEditText);
		calculateButton = (Button) findViewById(R.id.torqueCalc_calculateButton);
		calculateButton.setOnClickListener(torqueCalculate);
	}

	public float getForce() {
		return Float.parseFloat(forceEditText.getText().toString());
	}

	public float getDistance() {
		return Float.parseFloat(distanceEditText.getText().toString());
	}

	public float calculateTorque() {
		return getForce() * getDistance();
	}

	private OnClickListener torqueCalculate = new OnClickListener() {
		public void onClick(View v) {
			showAlert("Torque output", 0, Float.toString(calculateTorque())+" lbs/ft", "Torque-tastic", false);
		}

	};
}
